package com.zi.experttalk.experttalk.View;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import com.zi.experttalk.experttalk.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by jing on 2014/12/11.
 */
public class GongGaoListActivity extends Activity {
    private Button gongGaoListButton;
    private ListView gongGaoListListView;
    private List<String> list = new ArrayList<String>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.gonggaoliebiao);

        /**
         * 公告ListView绑定数据
         */
        init();
        gongGaoListListView = (ListView) findViewById(R.id.gonggaoliebiao_gonggaolist_ListView);
        GongGaoAdapter adapter = new GongGaoAdapter();
        gongGaoListListView.setAdapter(adapter);
    }

    class GongGaoAdapter extends BaseAdapter {

        @Override
        public int getCount() {
            return list.size();
        }

        @Override
        public Object getItem(int position) {
            return list.get(position);
        }

        @Override
        public long getItemId(int position) {
            return 0;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            String gongGaoStr = (String) getItem(position);
            View view = LayoutInflater.from(GongGaoListActivity.this).inflate(R.layout.gonggaolistitem,null);
            TextView textView = (TextView) view.findViewById(R.id.gonggaolistItem_gonggao_TextView);
            textView.setText(gongGaoStr);
            return view;
        }
    }

    //测试数据
    private void init(){
        list.add("吃好喝好");
        list.add("你好我们");
    }

}
